/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2019-2019.
 * Description: decompress.h
 * Author: chenjianguo
 * Create: 2019-01-27
 */
#ifndef ARM64_MISC_H
#define ARM64_MISC_H
extern unsigned long free_mem_ptr;
extern unsigned long free_mem_end_ptr;
extern unsigned char *output_data;
extern void error(char *) __noreturn;

#ifdef CONFIG_RTOS_CFI_MODE_ENFORCING
/*
 * rtos_hcfi_logger - a routine used for HCFI when checking tag of target symbol
 * failed in enforcing mode.
 * this routine does nothing, just ignoring tag inconsistencies, since this
 * function can only be triggered in decompressing the kernel image stage, that
 * is almost safe.
 * it is a temporary solution currently.
 * in the future, the HCFI feature will be improved on this portion.
 */
extern void rtos_hcfi_report(void);
#endif /* CONFIG_RTOS_CFI_MODE_ENFORCING */

#ifdef CONFIG_RTOS_CFI_MODE_PERMISSIVE
/*
 * rtos_hcfi_logger - a routine used for HCFI when checking tag of target symbol
 * failed in permissive mode.
 * this routine does nothing, just ignoring tag inconsistencies, since this
 * function can only be triggered in decompressing the kernel image stage, that
 * is almost safe.
 * it is a temporary solution currently.
 * in the future, the HCFI feature will be improved on this portion.
 */
extern void rtos_hcfi_logger(void);
#endif /* CONFIG_RTOS_CFI_MODE_PERMISSIVE */

/* Not needed, but used in some headers pulled in by decompressors */
extern char *strstr(const char *s1, const char *s2);
extern char input_data[];
extern char input_data_end[];
extern int do_decompress(u8 *input, int len, u8 *output, void (*error)(char *x));
#ifdef CONFIG_RTOS_KASAN
extern int memcmp(const void *cs, const void *ct, size_t count);
#endif
#endif
